package com.alkalinesolutions.json.core;

import com.alkalinesolutions.json.core.impl.JSONTextWalker;
import com.alkalinesolutions.json.core.impl.StructureEmitter;

public class JSONParser {
	private final JSONTextWalker cursor;
	private final StructureEmitter handler;

	public JSONParser() {
		cursor = new JSONTextWalker(this);
		handler = new StructureEmitter();
	}

	public Object parseText(final String text) throws JSONException {
		cursor.loadText(text);
		return handler.parse(cursor);
	}

	public void setStackDepth(final int stackDepth) {
		cursor.setStackDepth(stackDepth);
	}

	public int getStackDepth() {
		return cursor.getStackDepth();
	}

	public void setMaxLength(final int maxLength) {
		cursor.setMaxLength(maxLength);
	}

	public int getMaxLength() {
		return cursor.getMaxLength();
	}
}
